$(function()
{
	//TileViewer.config({"tileWidth":100,"tileHeight":100});
	//TileViewer.setAnimationDuration(2000);
	TileViewer.setViewportContainer($("#viewport"));
	
	function setTileWrapper(x,y, info)
	{return function(){TileViewer.updateTile(x,y , info);}}
	var fakeScroll = 0;
	function randInit()
	{
	for (var x= 0;x<64;x++)
	{
		for (var y=0;y<64;y++)
		{
			setTimeout(setTileWrapper(x,y, ""+ (x+y+fakeScroll)),  Math.random()* 500);
		}
	}
	}
	randInit();
	
	var button = $("<div></div>");
	button.text("click me");
	button.css("position","absolute");
	button.css("left",700);
	button.click(function()
	{
		try
		{
		fakeScroll++;
		//TileViewer.updateTile(1,1 , ""+ Math.random()* 99);
		randInit();
		}
		catch(err)
		{
			alert(err);
		}
		setTimeout(function ()
		{
			var a=5;
		}, 2000);
	});
	$(document.body).append(button);
});